import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 宝石和石头
 * 查询拥有的石头宝石的数量
 * User: xwl
 */
public class Test1 {
      public int numJewelsInStones(String jewels, String stones) {
          int count = 0;
          Set<Character> set = new HashSet<>();
          // 遍历jewels
          for (int i = 0; i < jewels.length(); i++) {
              char ch = jewels.charAt(i);
              set.add(ch);
          }
          // 遍历stones
          for (int i = 0; i < stones.length(); i++) {
              char ch = stones.charAt(i);
              if (set.contains(ch)) {
                  count++;
              }
          }
          // 返回
          return count;
      }
}
